
package Barang;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Astri
 */
public class BarangTableModel extends AbstractTableModel {
       private List<Barang> brg = new ArrayList<Barang>();

public BarangTableModel(List<Barang> barang){
    this.brg=barang;
}
    public int getRowCount() {
        return brg.size();
    }

    public int getColumnCount() {
        return 6;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
      Barang b =brg.get(rowIndex);
       switch(columnIndex){
           case 0:
               return b.getKodeBarang();
           case 1 :
               return b.getNamaBarang();
           case 2:
               return b.getJenisBarang();
           case 3:
               return b.getHargaJual();
           case 4:
               return b.getHargaBeli();
           case 5:
               return b.getJumlahStockAwal();

           default :
               return "";
       }
    }
    public String getColumnName (int column){
        switch(column){
            case 0 :
                return "Kode Barang";
            case 1 :
                return "Nama Barang";
             case 2 :
                return "Jenis Barang";
             case 3 :
                return "Harga Jual (Rp)";
             case 4 :
                return "Harga Beli (Rp)";
             case 5 :
                return "Jumlah Stock Awal";
             default:
                 return "";
        }
    }

}

